package www.lagou.app;

import www.lagou.dao.EmployeeDao;
import www.lagou.entity.Employee;
import www.lagou.entity.Phone;

import java.sql.SQLException;
import java.util.List;

public class Test3 {


    public static void main(String[] args) {
        EmployeeDao employeeDao = new EmployeeDao();
        List<Employee> list = null;

        try {
            list = employeeDao.findEmployeeByNull();
            System.out.println("需求1: ");
            for (Employee employee:list){
                System.out.println(employee.toString());
            }

            list = employeeDao.findEmployee();
            System.out.println("需求2: ");
            for (Employee employee:list){
                show(employee);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }

    public static void show(Employee employee){
        if (employee.getDept() != null) {
            System.out.println("姓名：" + employee.getNAME() + ",薪资：" + employee.getSalary() + ",所属部门名称：" + employee.getDept().getDeptname());
        }else {
            System.out.println("姓名：" + employee.getNAME() + ",薪资：" + employee.getSalary() + ",所属部门名称：没有所属部门");
        }
    }
}


